home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / shadow-3.1.4 / tz.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  927 b   |  42 lines

  1. /*
  2.  * Copyright 1991, John F. Haugh II and Chip Rosenthal
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #ifndef lint
  13. static    char    sccsid[] = "@(#)tz.c    3.1    07:47:56    9/17/91";
  14. #endif
  15.  
  16. #include <stdio.h>
  17.  
  18. /*
  19.  * tz - return local timezone name
  20.  *
  21.  * Tz() determines the name of the local timezone by reading the
  22.  * contents of the file named by ``fname''.
  23.  */
  24.  
  25. char *
  26. tz (fname)
  27. char    *fname;
  28. {
  29.     FILE *fp;
  30.     static char tzbuf[64];
  31.  
  32.     if ((fp = fopen(fname,"r")) == NULL)
  33.         return "TZ=CST6CDT";
  34.     else if (fgets(tzbuf, sizeof(tzbuf), fp) == NULL)
  35.         strcpy(tzbuf, "TZ=CST6CDT");
  36.     else
  37.         tzbuf[strlen(tzbuf) - 1] = '\0';
  38.  
  39.     (void) fclose(fp);
  40.     return tzbuf;
  41. }
  42.